package com.flex.model
{
 	import com.adobe.cairngorm.model.ModelLocator;
 	
 	import mx.messaging.Channel;
 	import mx.messaging.ChannelSet;
 	import mx.messaging.channels.AMFChannel;

 	[Bindable]
	public class ModelLocatorI implements com.adobe.cairngorm.model.ModelLocator
	{
		private static var modelLocator : ModelLocatorI;
		
		public static function getInstance() : ModelLocatorI 
		{
			if ( modelLocator == null )
				modelLocator = new ModelLocatorI();
				
			return modelLocator;
	    }
	   
	   	public function ModelLocatorI() 
	   	{
	   		if ( modelLocator != null )
					throw new Error( "Only one ModelLocator instance should be instantiated" );	
			
			initModel();
	   	}
		
		private function initModel():void{
		    var modelChannel:Channel = new AMFChannel("my-amf", "http://localhost:8080/compare/messagebroker/amf");
			channelSet = new ChannelSet();
			channelSet.addChannel(modelChannel);
		}
		
		public var channelSet:ChannelSet;
	}	
}

